home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’95 / NetFractal™ / Fractal 8 source / Fractal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-24  |  3.6 KB  |  151 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Fractal.h
  3.  
  4.     Used to build:    “Fractal 8”
  5.     
  6.     Written by:        Jim Cathey            July 1985
  7.                     Eric Traut            November 1994
  8.  
  9.     Description:
  10.         See comments in the file “FractalMain.c” for more
  11.         information.
  12. */
  13.  
  14. #pragma cplusplus off
  15.  
  16. #include <QDOffscreen.h>
  17.  
  18. /* Menu information */
  19. enum {
  20.     kMenuBarID            = 128,
  21.     kAppleMenuID        = 128,
  22.     kAboutBoxItem        = 1,
  23.     kFileMenuID            = 129,
  24.     kNewFractalItem        = 1,
  25.     kQuitItem            = 3,
  26.     kEditMenuID            = 130,
  27.     kOptionsMenuID        = 131,
  28.     kSetupItem            = 1,
  29.     kContinuousItem        = 3,
  30.     kMorphItem            = 4,
  31.     kDrawSurfaceItem    = 5
  32. };
  33.  
  34. /* Window, dialog, and alert constants */
  35. enum {
  36.     kMainWindowID            = 260,
  37.     kAboutBox1DialogID        = 256,
  38.     kAboutBoxOKButtonID        = 1,
  39.     kAboutBoxMoreButtonID    = 2,
  40.     kAboutBox2DialogID        = 257,
  41.     kFatalErrorAlertID        = 128
  42. };
  43.  
  44. /* Setup dialog constants */
  45. enum {
  46.     kSetUpDialogID            = 258,
  47.     kSetUpOKButtonID        = 1,
  48.     kSetUpCancelButtonID    = 2,
  49.     kSetUpLevelID            = 4,
  50.     kSetUpMtnButtonID        = 5,
  51.     kSetUpHillsButtonID        = 6,
  52.     kSetUpWaterButtonID        = 7
  53. };
  54.  
  55. /* Style and level constants */
  56. enum {
  57.     kStyleMountains            = kSetUpMtnButtonID,
  58.     kStyleHills                = kSetUpHillsButtonID,
  59.     kStyleWater                = kSetUpWaterButtonID,
  60.     kMaxLevel                = 7,
  61.     kDefaultStyle            = kStyleWater,
  62.     kDefaultLevel            = 6
  63. };
  64.  
  65. enum {
  66.     kMaxXPoint                = ((1 << kMaxLevel) + 1) + 1,
  67.     kMaxYPoint                = ((1 << (kMaxLevel - 1)) + 1) + 1
  68. };
  69.  
  70. /* Screen constants */
  71.  
  72. #if 1
  73. enum {
  74.     kNewScreenX                = 630,
  75.     kNewScreenY                = 434,
  76.     kScaleShift                = 5,
  77.     kScreenBoundaryBits        = 5,
  78.     kWindowTitleHeight        = 16,
  79.     kTotalGrays                = 256
  80. };
  81.  
  82. enum {
  83.     kXOrigin                = 40,
  84.     kYOrigin                = 108,
  85.     kYMountainOrigin        = 330
  86. };
  87.  
  88. enum {
  89.     kShadeMapSize        = 256,
  90.     kVectorBaseSize        = 16
  91. };
  92. #else
  93. enum {                                    // original values
  94.     kNewScreenX                = 630,
  95.     kNewScreenY                = 434,
  96.     kScaleShift                = 5,
  97.     kScreenBoundaryBits        = 5,
  98.     kWindowTitleHeight        = 16,
  99.     kTotalGrays                = 256
  100. };
  101.  
  102. enum {
  103.     kXOrigin                = 40,
  104.     kYOrigin                = 108,
  105.     kYMountainOrigin        = 330
  106. };
  107.  
  108. enum {
  109.     kShadeMapSize        = 256,
  110.     kVectorBaseSize        = 16
  111. };
  112. #endif
  113.  
  114. /* Types used in fractal */
  115. struct ThreePoint {
  116.     short        x;
  117.     short        y;
  118.     short        z;
  119. };
  120. typedef struct ThreePoint ThreePoint;
  121.  
  122. /* Global variables used in multiple files */
  123. extern short (*gOldPointArray)[kMaxXPoint][kMaxYPoint];        
  124.                                             /* The array of points to be subdivided. */
  125. extern short (*gNewPointArray)[kMaxXPoint][kMaxYPoint];        
  126.                                             /* The array of points to be subdivided. */
  127. extern ThreePoint (*gPlotPointArray)[2 * kMaxXPoint][2 * kMaxYPoint];
  128.                                             /* The array of points to be subdivided */
  129. extern short gContourType;                    /* Contour type */
  130. extern short gContourLevel;                    /* Level of detail */
  131. extern short gMainWindowHeight;                /* Height of main window */
  132. extern short gMainWindowWidth;                /* Width of main window */
  133. extern long gMicrosecondCount;                /* Total time spent calculating and drawing */
  134. extern long gTotalFractals;                    /* Total fractal count */
  135. extern Boolean gFractalChanged;                /* Should this screen update be counted? */
  136. extern GWorldPtr gOffscreenGWorld;            /* GWorld for faster drawing */
  137. extern PixMapHandle    gOffscreenPixMap;        /* Offscreen PixMap */
  138. extern WindowPtr gMainWindow;                /* Our one window */
  139. extern float gMorphAmount;                    /* Percent of morph complete */
  140. extern float gMorphAmountNeg;
  141. extern Boolean gContinuousRedraw;            /* Continuously redraw fractal */
  142. extern Boolean gMorphFractal;                /* Morph or not morph */
  143. extern unsigned short gShadeMap[kShadeMapSize];
  144.  
  145. void CalcSurface(unsigned short level);
  146. void PlotData(Boolean plotSurface);
  147. void SetBlitBuffer(unsigned char *blitData, Rect *blitBounds, short blitRowBytes);
  148. void FillTriangle(long vertex1H, long vertex1V, long vertex2H, long vertex2V, long vertex3H, long vertex3V, unsigned char color);
  149.  
  150.  
  151.